package com.it.mybatis.model;

/**
 * @Author LHN
 * @ClassName ApiModel
 * @Date 2021/10/17
 * @Description }
 */
public class ApiModel {
    private static final Integer STATUS_SUCCESS = 200;
    private static final Integer STATUS_FAIL = 404;
    private static final Integer STATUS_ERROR = 500;

    private Integer statusCode;
    private String msg;
    private Object data;

    public ApiModel() {
    }

    public ApiModel(Integer statusCode, String msg) {
        this.statusCode = statusCode;
        this.msg = msg;
    }
    public ApiModel(Integer statusCode, String msg, Object data) {
        this.statusCode = statusCode;
        this.msg = msg;
        this.data = data;
    }

    public static ApiModel ok(){
        return new ApiModel(STATUS_SUCCESS,"成功");
    }

    public static ApiModel ok(Object data){
        return new ApiModel(STATUS_SUCCESS,"成功",data);
    }

    public static ApiModel fail(){
        return new ApiModel(STATUS_FAIL,"失败");
    }

    public static ApiModel fail(Object data){
        return new ApiModel(STATUS_FAIL,"失败",data);
    }

    public Integer getStatusCode() {
        return statusCode;
    }

    public void setStatusCode(Integer statusCode) {
        this.statusCode = statusCode;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
